home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / Tools & Goodies / IntlTest / Sources / EditViews.h < prev    next >
Encoding:
Text File  |  1996-04-23  |  7.1 KB  |  240 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                EditViews.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Author:                Mary Boetcher
  7. //
  8. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef EDITVIEWS_H
  13. #define EDITVIEWS_H
  14.  
  15. #ifndef COMMANDS_H
  16. #include "Commands.h"
  17. #endif
  18.  
  19. // ----- Part Layer -----
  20.  
  21. #ifndef FWEDVIEW_H
  22. #include "FWEdView.h"
  23. #endif
  24.  
  25. #ifndef FWSCPTBL_H
  26. #include "FWScptbl.h"
  27. #endif
  28.  
  29. // ----- Macintosh Includes -----
  30.  
  31. #ifndef __TEXTEDIT__
  32. #include <TextEdit.h>
  33. #endif
  34.  
  35. #ifndef __TEXTSERVICES__
  36. #include <TextServices.h>
  37. #endif
  38.  
  39. #ifndef __TSMTE__
  40. #include <TSMTe.h>
  41. #endif
  42.  
  43. //========================================================================================
  44. // Forward Declarations
  45. //========================================================================================
  46.  
  47. class CIntlTestPart;
  48. class FW_CViewContext;
  49. class FW_CMouseEvent;
  50. class FW_CClipboardCommand;
  51. class CTypingCommand;
  52. class CTSMTypingCommand;
  53.  
  54. //========================================================================================
  55. // Constants and Globals
  56. //========================================================================================
  57.  
  58. extern FW_CFont gFontOsaka;
  59.  
  60. const FW_Message kEditViewMsg = 45;    // ASCII 'E'
  61.  
  62. //----------------------------------------------------------------------------------------
  63. // Enumeration for ASCII Character Constants - copied from MacApp
  64. //----------------------------------------------------------------------------------------
  65.  
  66. enum EAsciiControlCode {
  67.     chBackspace = 8,                    // ASCII code for Backspace character  
  68.     chClear = 27,                        // ASCII code for Clear key (aka ESC)  
  69.     chDown = 31,                        // ASCII code for down arrow  
  70.     chEnd = 4,                            // ASCII code for the End key  
  71.     chEnter = 3,                        // ASCII code for Enter character  
  72.     chEscape = 27,                        // ASCII code for Escape (aka Clear) key  
  73.     chFunction = 16,                    // ASCII code for any function key  
  74.     chFwdDelete = 127,                    // ASCII code for forward delete  
  75.     chHelp = 5,                            // ASCII code for Help key  
  76.     chHome = 1,                            // ASCII code for the Home key  
  77.     chLeft = 28,                        // ASCII code for left arrow  
  78.     chPageDown = 12,                    // ASCII code for Page Down key  
  79.     chPageUp = 11,                        // ASCII code for Page Up key  
  80.     chReturn = 13,                        // ASCII code for Return character  
  81.     chRight = 29,                        // ASCII code for right arrow  
  82.     chSpace = 32,                        // ASCII code for Space character  
  83.     chTab = 9,                            // ASCII code for Tab character  
  84.     chUp = 30                            // ASCII code for up arrow
  85. };
  86.  
  87. //========================================================================================
  88. // FW_MTSMHandler - a mixin for views that use the Text Services Manager
  89. //========================================================================================
  90. class FW_MTSMHandler
  91. {
  92.   public:
  93.     FW_DECLARE_CLASS
  94.  
  95.     FW_MTSMHandler(FW_CEditView* theView);
  96.     virtual ~FW_MTSMHandler();
  97.  
  98.     FW_Boolean CreateTSMDocument(TEHandle te);
  99.  
  100.     FW_Boolean DoActivateTSM(FW_Boolean becomingActive);
  101.     FW_Boolean DoFixTSMDocument();
  102.  
  103.     TSMDocumentID GetTSMDocument() const;
  104.     void SetTSMDocument(TSMDocumentID docId);
  105.  
  106.   private:
  107.     TSMDocumentID    fTSMDocId;
  108.     TSMTERecHandle    fTSMHandle;
  109.     FW_CEditView*    fEditView;
  110.     OSErr            fError;        // error from last TSM call
  111. };
  112.  
  113. //----------------------------------------------------------------------------------------
  114. inline TSMDocumentID FW_MTSMHandler::GetTSMDocument() const
  115. {
  116.     return fTSMDocId;
  117. }
  118.  
  119. //----------------------------------------------------------------------------------------
  120. inline void FW_MTSMHandler::SetTSMDocument(TSMDocumentID docId)
  121. {
  122.     fTSMDocId = docId;
  123. }
  124.  
  125. //========================================================================================
  126. // CEditNotification
  127. //========================================================================================
  128. class CEditNotification : public FW_CNotification
  129. {
  130.   public:
  131.     CEditNotification(FW_CEditView* editView);
  132.     CEditNotification(const CEditNotification& other);
  133.     virtual ~CEditNotification();
  134.  
  135.     FW_Boolean            operator==(const CEditNotification& other);
  136.     CEditNotification&    operator=(const CEditNotification& other);
  137.     
  138.     FW_CEditView*        GetEditView(Environment* ev) const;
  139.     ODID                GetViewId(Environment* ev) const;
  140.     
  141.   private:
  142.     FW_CEditView*        fEditView;
  143. };
  144.  
  145. //----------------------------------------------------------------------------------------
  146. inline FW_CEditView* CEditNotification::GetEditView(Environment* ev) const
  147. {
  148.     return fEditView;
  149. }
  150.  
  151. //----------------------------------------------------------------------------------------
  152. inline ODID CEditNotification::GetViewId(Environment* ev) const
  153. {
  154.     return fEditView->GetViewId(ev);
  155. }
  156.  
  157. //========================================================================================
  158. // CMyEditView - experiment with typing Undo/Redo
  159. //========================================================================================
  160. class CMyEditView : public FW_CEditView
  161. {
  162.   public:
  163.     FW_DECLARE_CLASS
  164.     FW_DECLARE_AUTO(CMyEditView)
  165.  
  166.   public:        
  167.     CMyEditView(Environment* ev,
  168.                 FW_CSuperView* container, 
  169.                 ODID viewId,
  170.                 const FW_CRect& bounds,
  171.                 const FW_CFont& font,
  172.                 short maxChars,
  173.                 unsigned short attributes);
  174.     virtual ~ CMyEditView();
  175.  
  176.   public:
  177.     virtual void        DeactivateTarget(Environment* ev);
  178.     virtual FW_Boolean    DoCharKey(Environment* ev, const FW_CCharKeyEvent& event);
  179.     virtual FW_Boolean    DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent);
  180.     virtual FW_Boolean    DoMouseDown(Environment* ev, const FW_CMouseEvent& event);
  181.  
  182.     void                LinkToReceiver(FW_MReceiver* receiver);
  183.  
  184.   protected:
  185.     void                DoneTyping(Environment* ev);
  186.     FW_Boolean            IsArrowKey(char ch);
  187.  
  188.   private:
  189.     CTypingCommand*        NewTypingCommand(Environment* ev, char firstChar);
  190.  
  191.   protected:
  192.     CTypingCommand*        fTypingCommand;
  193. };
  194.  
  195. //========================================================================================
  196. // CJapEditView
  197. //========================================================================================
  198. class CJapEditView : public CMyEditView, public FW_MTSMHandler
  199. {
  200.   public:
  201.     FW_DECLARE_CLASS
  202.     FW_DECLARE_AUTO(CJapEditView)
  203.  
  204.   public:        
  205.     CJapEditView(Environment* ev,
  206.                  FW_CSuperView* container, 
  207.                  ODID viewId,
  208.                  const FW_CRect& bounds,
  209.                  const FW_CFont& font,
  210.                  short maxChars,
  211.                  unsigned short attributes);
  212.     virtual ~ CJapEditView();
  213.  
  214.     void                InitJapEditView(Environment* ev);
  215.  
  216.   public:
  217.     virtual void         ActivateTarget(Environment* ev, FW_Boolean tabSelection);
  218.     virtual void         DeactivateTarget(Environment* ev);
  219.  
  220.     virtual FW_Boolean    DoCharKey(Environment* ev, const FW_CCharKeyEvent& event);
  221.     virtual FW_Boolean    DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent);
  222.  
  223.   public:
  224.     void                AddInput(Environment* ev, CTSMInput* input);
  225.     void                DoMakeTypingCommand(Environment* ev = NULL);
  226.     FW_Boolean            IsFirstEventInSequence();
  227.  
  228.   private:
  229.     CTSMTypingCommand*    NewTypingCommand(Environment* ev, CTSMInput* firstInput);
  230.     CTSMTypingCommand*    fTSMTypingCommand;
  231.  
  232.   private:
  233.     short        fMyFont;                // my font
  234.     short        fMyFontScript;            // my font's script
  235.     short        fPreviousFontScript;    // font script saved on activation
  236.     FW_Boolean    fFirstActivation;
  237. };
  238.  
  239.  
  240. #endif